home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-02-26 | 21.4 KB | 857 lines | [TEXT/MPS ] |
-
- (* This procedure gathers all the info about the current movie's time base *)
- (* routines that modify the state of the time base will keep this up to date *)
- (* Important to note here is that duration is specified in movie scale units *)
-
- PROCEDURE InitTBRecord(moov: Movie);
- VAR tb: TimeBase;
- scale: TimeScale;
- startTimeValue,
- stopTimeValue: TimeValue;
- clock: ComponentInstance;
- clockN: StringHandle;
- err: OSErr;
- cd: ComponentDescription;
-
- BEGIN
- clockN := StringHandle(NewHandle(256)); (* good length for string *)
-
- tb := GetMovieTimeBase(gMoov); (* get movie's time base *)
- scale := GetMovieTimeScale(gMoov); (* and the scale *)
- clock:= GetTimeBaseMasterClock(tb); (* instance of clock being used *)
- err := GetComponentInfo(Component(clock), cd, Handle(clockN), NIL, NIL); (* also takes instances *)
-
- WITH gTBState DO
- BEGIN
- tBase := tb;
- gTBState.flags := GetTimeBaseFlags(tb);
- rate := GetTimeBaseRate(tb);
-
- startTimeValue := GetTimeBaseStartTime(tb, scale, startTime);
- stopTimeValue := GetTimeBaseStopTime(tb, scale, stopTime);
- duration := stopTimeValue - startTimeValue;
- IF clockN <> NIL THEN (* have a name *)
- BEGIN
- clockName := clockN^^;
- END;
- moovScale := scale;
- END;
- DisposeHandle(Handle(clockN));
- END;
-
- (* Changes the state of looping in the movie if needed.
- *)
- PROCEDURE SetTBLoop(newFlags: LONGINT);
- VAR targetTB: TimeBase;
-
- BEGIN
- targetTB := gTBState.tBase;
- SetTimeBaseFlags(targetTB, newFlags);
- gTBState.flags := newFlags;
- END;
-
- (*********** Auxiliary routines ********************************************************)
-
- (* Loads in a resource of type RCT#, a list of rectangles and passes back
- the rect pointed to by index
- *)
- PROCEDURE GetIndRect(ID: Integer; index: Integer; VAR targetRect: Rect);
- VAR resHandle: RectsRecHandle;
- theRects: Ptr;
- limit: Integer;
- r : Rect;
-
- BEGIN
- resHandle := RectsRecHandle(GetResource('RCT#', ID));
- IF ((resHandle <> NIL) AND (resHandle^^.rectCount >= index)) THEN
- BEGIN
- targetRect := resHandle^^.rects[index];
- END
- ELSE
- SetRect(targetRect, 0, 0, 0, 0); (* empty rect signals failure *)
- END;
-
-
- (* Handy little routine used to display values in hex *)
- procedure NumToHex (n: Longint; w: Integer; var s: Str255);
- const
- hex = '0123456789ABCDEF';
- var
- i: Integer;
- begin
- s := '$00000000';
- for i := 0 to w - 1 do
- begin
- s[9 - i] := hex[BitAnd(n, $0000000F) + 1];
- n := BitShift(n, -4);
- end;
- end;
-
- PROCEDURE ErrorControl(message: Str255);
-
- BEGIN
- DebugStr(message);
- END;
-
- (* Display state values from Time base state record *)
- PROCEDURE DrawContents;
- VAR r: Rect;
- where: Point;
- s, s2: STR255;
- aFix: Fixed;
- fNum: Integer;
- sysFont: Str255;
- startTimeValue,
- stopTimeValue : TimeValue;
- startTime, stopTime: TimeRecord;
-
- BEGIN
- GetFNum('Courier', fNum); (* want to set our font *)
-
- IF fNum <> 0 THEN (* but only when available *)
- TextFont(fNum)
- ELSE (* make sure that 0 is the correct result IM VI 12-16 *)
- BEGIN
- GetFontName(0, sysFont);
- IF EqualString('Courier', sysFont, FALSE, FALSE) THEN
- TextFont(fNum)
- END;
-
- (* Display movie duration *)
-
- (* All the strings are postioned
- using rectangles that are kept in a RCT# resource.
- *)
- GetIndRect(rRCTID, 0, r);
- MoveTo(r.left, r.bottom - 3);
- DrawString('Duration = ');
-
- NumToString(gTBState.duration, s);
- GetIndRect(rRCTID, 1, r);
- MoveTo(r.right - (StringWidth(s) + 2), r.bottom - 3);
-
- EraseRect(r);
- FrameRect(r);
- DrawString(s);
-
- NumToString(gTBState.moovScale, s);
- s := Concat(' 1/',s);
- GetIndRect(rRCTID, 2, r);
- MoveTo(r.right - (StringWidth(s) + 2), r.bottom - 3);
- EraseRect(r);
- FrameRect(r);
- DrawString(s);
- Move(2,0);
- DrawString('th. sec.');
-
- (* Display movie rate information *)
-
- GetIndRect(rRCTID, 3, r);
- MoveTo(r.left, r.bottom - 3);
- DrawString('Rate Settings');
-
- GetIndRect(rRCTID, 4, r);
- MoveTo(r.left, r.bottom - 3);
- DrawString('Current = ');
-
- GetIndRect(rRCTID, 5, r);
- NumToHex(gTBState.rate,8, s);
- MoveTo(r.right - (StringWidth(s) + 2), r.bottom - 3);
-
- EraseRect(r);
- FrameRect(r);
- DrawString(s);
-
- GetIndRect(rRCTID, 6, r);
- MoveTo(r.left, r.bottom - 3);
- DrawString('Preferred = ');
-
- GetIndRect(rRCTID, 7, r);
- aFix := GetMoviePreferredRate(gMoov);
- NumToHex(aFix,8, s);
- MoveTo(r.right - (StringWidth(s) + 2), r.bottom - 3);
-
- EraseRect(r);
- FrameRect(r);
- DrawString(s);
-
- (* display clock name *)
-
- GetIndRect(rRCTID, 8, r);
- MoveTo(r.left, r.bottom - 3);
- s := Concat('ClockName = ',gTBState.clockName);
- DrawString(s);
-
- (* Display start and stop values *)
-
- startTimeValue := GetTimeBaseStartTime(gTBState.tBase, gTBState.moovScale, startTime);
- stopTimeValue := GetTimeBaseStopTime(gTBState.tBase, gTBState.moovScale, stopTime);
-
- GetIndRect(rRCTID, 9, r);
- MoveTo(r.left, r.bottom - 3);
- DrawString('Start = ');
-
- NumToString(startTimeValue, s);
- GetIndRect(rRCTID, 10, r);
- MoveTo(r.right - (StringWidth(s) + 2), r.bottom - 3);
-
- EraseRect(r);
- FrameRect(r);
- DrawString(s);
-
- GetIndRect(rRCTID, 11, r);
- MoveTo(r.left, r.bottom - 3);
- DrawString('Stop = ');
-
- NumToString(stopTimeValue, s);
- GetIndRect(rRCTID, 12, r);
- MoveTo(r.right - (StringWidth(s) + 2), r.bottom - 3);
-
- EraseRect(r);
- FrameRect(r);
- DrawString(s);
-
- END;
-
- (* boolean parameter tells if we have to erase and frame or just redraw the string *)
- PROCEDURE DrawShuttleValue(doAll: Boolean);
- VAR valueS: Str255;
- theRect: Rect;
- tb: TimeBase;
- outTime: TimeRecord;
- tv: TimeValue;
- value: Integer;
- BEGIN
- theRect := gShuttle^^.contrlRect;
- value := gShuttle^^.contrlValue;
- InsetRect(theRect, 28,32);
- EraseRect(theRect);
- InsetRect(theRect, 1, 1);
- IF doAll THEN
- FrameRect(theRect);
- MoveTo(theRect.left+2, theRect.bottom-4);
- NumToString(value, valueS);
- InsetRect(theRect, 1, 1);
- DrawString(valueS);
- END;
- {
- Shuttle button calls this proc when tracking so that I can update the value. It also gets
- called when SetCtrlValue is called.
- }
- PROCEDURE TrackingActionProc;
- VAR value: Integer;
-
- BEGIN
-
- DrawShuttleValue(FALSE);
-
- (* The shuttle control allows to scan the movie forward or backward
- one ' movie scale/10' tick at the time.
- *)
-
- SetTimeBaseValue(gTBState.tBase, value*10, gTBState.moovScale);
- MoviesTask(gMoov, doTheRightThing); (* let the movie move during long trackings *)
- END;
-
- PROCEDURE HandleGoAway(WPtr : WindowPtr; MLoc : Point);
- {
- purpose handle mouse click in go-away box
- }
- VAR
- WPeek : WindowPeek; { for looking at windows }
- BEGIN
- IF WPtr = FrontWindow THEN { if it's the active window }
- BEGIN
- WPeek := WindowPeek(WPtr); { peek at the window }
- IF TrackGoAway(WPtr,MLoc) THEN { and the box is clicked }
- IF WPeek^.WindowKind = userKind THEN{ if it's our window }
- gDoneFlag := True { then time to stop }
- END
- ELSE
- SelectWindow(WPtr) { else make it active }
- END; { of proc HandleGoAway }
-
- (* Given a window and a control returns the id of the control.
- Note that this works only because I know the order in which controls are added
- in and also that controls are not deleted.
- If result is -1 then we don't know what control is it.
- Controls get attached firs come first served, so the list is
- last first.
- *)
- FUNCTION GetControlID(whichControl: ControlHandle; wind: WindowPtr): Integer;
- VAR nextCon: ControlHandle;
- count: Integer;
-
- BEGIN
- nextCon := WindowPeek(wind)^.controlList;
- count := lastControl; (* last control *)
-
- WHILE whichControl <> nextCon DO
- BEGIN
- nextCon := nextCon^^.nextControl;
- IF nextCon = NIL THEN
- BEGIN
- count := -1;
- LEAVE
- END
- ELSE
- count := count-1;
- END;
- GetControlID := count;
- END;
-
- (* Returns the control handle given an controlID *)
- (* Controls are put in the list in last in first in list order *)
- FUNCTION GetControlFromID(id: Integer;wind: WindowPtr): ControlHandle;
- VAR nextCon: ControlHandle;
- count: Integer;
-
- BEGIN
- nextCon := WindowPeek(wind)^.controlList;
- FOR count := 1 TO lastControl - id DO
- BEGIN
- nextCon := nextCon^^.nextControl;
- IF nextCon = NIL THEN LEAVE
- END;
- GetControlFromID := nextCon;
- END;
-
- PROCEDURE SetLoop( id: INTEGER);
- VAR controlH: ControlHandle;
-
- BEGIN
- CASE id OF
- 129:
- BEGIN
- controlH := GetControlFromID(129, gWind);
- IF GetCtlValue(controlH) = 0 THEN (* loop is on *)
- BEGIN
- SetTBLoop(0); (* no loop *)
- SetCtlValue(controlH, 1);
- controlH := GetControlFromID(130, gWind);
- SetCtlValue(controlH, 0);
- controlH := GetControlFromID(131, gWind);
- SetCtlValue(controlH, 0);
- END
- END;
- 130:
- BEGIN
- controlH := GetControlFromID(130, gWind);
- IF GetCtlValue(controlH) = 0 THEN
- BEGIN
- SetTBLoop(loopTimeBase); (* normal loop *)
- SetCtlValue(controlH, 1);
- controlH := GetControlFromID(129, gWind);
- SetCtlValue(controlH, 0);
- controlH := GetControlFromID(131, gWind);
- SetCtlValue(controlH, 0);
- END
- END;
- 131:
- BEGIN
- controlH := GetControlFromID(131, gWind);
- IF GetCtlValue(controlH) = 0 THEN
- BEGIN
- SetTBLoop(palindromeLoopTimeBase); (* palindrome loop *)
- SetCtlValue(controlH, 1);
- controlH := GetControlFromID(129, gWind);
- SetCtlValue(controlH, 0);
- controlH := GetControlFromID(130, gWind);
- SetCtlValue(controlH, 0);
- END
- END;
- END
- END;
-
- PROCEDURE CallSetCtlValueNoProc(shuttle: ControlHandle; newValue: Integer);
- BEGIN
- IF shuttle^^.contrlValue <> newValue THEN
- BEGIN
- SetCRefCon(gShuttle, 0); (* make sure my tracking is not called *)
-
- SetCtlValue(shuttle, newValue);
-
- SetCRefCon(gShuttle, LongInt(@TrackingActionProc));
-
- DrawShuttleValue(FALSE);
- END
- END;
-
- PROCEDURE InitControls(moov: Movie; wind: WindowPtr);
- VAR controlH: ControlHandle;
- value: Integer;
- TBFlags: LONGINT;
- rate: Fixed;
-
- FUNCTION ShuttleDuration: TimeValue;
- (* the movie duration is given in 'normal' movie rate units, this makes advancing the
- movie using the shuttle control a little too much work, so for the control we keep
- the duration at a coarser rate. We take the movie rate and convert it to its 1/10th.
- so if the movie rate is 600 (meaning 600 time units persecond or about 60 time units
- per video frame) the controller 'rate' is 60 or 6 of its units per video frame. This
- produces the effect of being able to scroll through the movie without having to go
- round and round and round and …
- *)
- VAR tr: TimeRecord;
- localDuration: TimeValue;
- shuttleScale : TimeScale;
- BEGIN
- WITH gTBState DO
- BEGIN
- shuttleScale := moovScale DIV 10;
- localDuration := GetTimeBaseStopTime(tBase, shuttleScale, tr);
- localDuration := localDuration - GetTimeBaseStartTime(tBase, shuttleScale, tr);
- END;
- ShuttleDuration := localDuration;
- END;
-
- BEGIN
- InitTBRecord(moov);
-
- SetCRefCon(gShuttle, 0); (* make sure my tracking is not called *)
- SetCtlMax(gShuttle, ShuttleDuration);
- SetCtlMin(gShuttle,0);
- SetCtlValue(gShuttle, 0);
-
- SetCRefCon(gShuttle, LongInt(@TrackingActionProc));
-
- TBFlags := gTBState.flags;
- CASE TBFlags OF
- 0:
- BEGIN
- controlH := GetControlFromID(129, gWind);
- SetCtlValue(controlH, 1);
- controlH := GetControlFromID(130, gWind);
- SetCtlValue(controlH, 0);
- controlH := GetControlFromID(131, gWind);
- SetCtlValue(controlH, 0);
- END;
- 1:
- BEGIN
- controlH := GetControlFromID(130, gWind);
- SetCtlValue(controlH, 1);
- controlH := GetControlFromID(129, gWind);
- SetCtlValue(controlH, 0);
- controlH := GetControlFromID(131, gWind);
- SetCtlValue(controlH, 0);
- END;
- 2:
- BEGIN
- controlH := GetControlFromID(131, gWind);
- SetCtlValue(controlH, 1);
- controlH := GetControlFromID(129, gWind);
- SetCtlValue(controlH, 0);
- controlH := GetControlFromID(130, gWind);
- SetCtlValue(controlH, 0);
- END;
- END; (* CASE *)
-
- (* init set preferred rate button *)
- controlH := GetControlFromID(132, gWind);
- HiliteControl(controlH, 255); (* disable until there is something to do *)
- rate := GetMoviePreferredRate(gMoov);
- SetCRefCon(controlH, rate);
-
- (* init reset preferred rate button *)
- controlH := GetControlFromID(133, gWind);
- rate := GetMoviePreferredRate(gMoov);
- SetCRefCon(controlH, rate);
-
- END;
-
-
- FUNCTION InArrows(loc: Point): BOOLEAN;
-
- BEGIN
- InArrows := PtInRect(loc, gArrows^^.picFrame);
- END;
-
- (* the user clicked on set rate so we go ahead and change the preferred rate *)
- PROCEDURE SetPreferredRate(id: Integer);
- VAR controlH: ControlHandle;
- new: Fixed;
- err: OSerr;
-
- BEGIN
- controlH := GetControlFromID(id, gWind);
- new := GetCRefCon(controlH);
- SetMoviePreferredRate(gMoov, new);
- err := GetMoviesError;
- IF err <> noErr THEN
- DebugStr('Could not set the movie rate');
- err := MCMovieChanged(gMCPlay, gMoov); (* let the controller know of the change *)
- HiliteControl(controlH, 255); (* we did set the rate, now disable *)
- END;
-
- (* we use the control refcon to keep the preferred rate, and we set it
- if the user clicks on the set button.
- *)
- PROCEDURE SetRefConRate(new: Fixed);
- VAR controlH: ControlHandle;
- old: Fixed;
-
- BEGIN
- controlH := GetControlFromID(132, gWind);
- old := GetCRefCon(controlH);
- IF new <> old THEN
- BEGIN
- HiliteControl(controlH, 0); (* enable to allow change *)
- SetCRefCon(controlH, new);
- END;
- END;
-
- (* the user clicked on reset rate; put preferred rate to the value the movie came
- with from the file *)
- PROCEDURE ResetPreferredRate(id: Integer);
- VAR controlH: ControlHandle;
- enteredPrefRate,
- rateFromFile: Fixed;
- err: OSerr;
- r: Rect;
-
- BEGIN
- controlH := GetControlFromID(id, gWind);
- rateFromFile := GetCRefCon(controlH);
- controlH := GetControlFromID(id - 1, gWind); (* if I am here, then the previous control *)
-
- SetMoviePreferredRate(gMoov, rateFromFile);
- err := MCMovieChanged(gMCPlay, gMoov);
- GetIndRect(rRCTID, 7, r);
- InvalRect(r);
- HiliteControl(controlH, 255); (* enable to allow change *)
- SetCRefCon(controlH, rateFromFile);
- END;
-
- (* When the user clicks on the arrows the selected rate decreases or increases
- through this function.
- *)
- PROCEDURE TrackArrows(loc: Point);
- VAR thePoint: Point;
- inUp,
- inDown: BOOLEAN;
- middle: Integer;
- topRect,
- bottomRect: Rect;
- upRgn, rRgn,
- downRgn: RgnHandle;
- poly: PolyHandle;
- rate: Fixed;
-
- PROCEDURE DrawRate;
- VAR r: Rect;
- where: Point;
- s: Str255;
-
- BEGIN
- GetIndRect(rRCTID, 7, r);
- NumToHex(rate,8, s);
- MoveTo(r.right - (StringWidth(s) + 2), r.bottom - 3);
-
- InsetRect(r,1,1);
- TextMode(srcCopy);
- DrawString(s);
- END;
-
- BEGIN
- upRgn := NewRgn;
- downRgn := NewRgn;
- rRgn := NewRgn;
- rate := GetCRefCon(GetControlFromID(132, gWind)); (* since we declare it, use it *)
-
- (* rather ugly way to get the correct shape for the arrows, it works though! *)
- topRect := gArrows^^.picFrame;
- OffsetRect(topRect,-1,-1);
- WITH topRect DO
- BEGIN
- OpenRgn;
- MoveTo(left+3,top+2);
- LineTo(right-2,top+2);
- LineTo(right, top+4);
- LineTo(right, bottom-2);
- LineTo(right-2,bottom);
- LineTo(left+3,bottom);
- LineTo(left+2,bottom-1);
- LineTo(left+2,top+4);
- LineTo(left+3,top+2);
- CloseRgn(rRgn);
- END;
-
- inUp:= FALSE;
- inDown:=FALSE;
- middle := (gArrows^^.picFrame.bottom-gArrows^^.picFrame.top) DIV 2;
-
- topRect := gArrows^^.picFrame;
- topRect.bottom := topRect.bottom - middle;
- bottomRect := gArrows^^.picFrame;
- bottomRect.top := bottomRect.top + middle;
-
- middle := bottomRect.top;
- RectRgn(upRgn, topRect);
- SectRgn(upRgn, rRgn, upRgn);
- RectRgn(downRgn, bottomRect);
- SectRgn(downRgn, rRgn, downRgn);
-
- REPEAT
- BEGIN
- GetMouse(thePoint);
- IF PtInRect(thePoint, gArrows^^.picFrame) THEN
- BEGIN
- IF thePoint.v < middle THEN (* mouse on top part *)
- BEGIN
- rate := rate + $00000010;
- DrawRate;
- IF inDown THEN
- BEGIN
- InvertRgn(downRgn); (* un hilite down arrow *)
- InvertRgn(upRgn); (* hilite up *)
- inDown := FALSE;
- END
- ELSE (* in up arrow again *)
- BEGIN
- IF NOT inUp THEN (* first time hilite the arrow *)
- InvertRgn(upRgn); (* hilite up *)
- END;
- inUp := TRUE
- END
- ELSE (* cursor is on top of down arrow *)
- BEGIN
- rate := rate + $FFFFFFF0;
- DrawRate;
- IF inUp THEN
- BEGIN
- InvertRgn(downRgn); (* un hilite down arrow *)
- InvertRgn(upRgn); (* hilite up *)
- inUp := FALSE;
- END
- ELSE (* in up arrow again *)
- BEGIN
- IF NOT inDown THEN
- InvertRgn(downRgn);
- END;
- inDown := TRUE
- END
- END
- ELSE
- BEGIN
- IF inUp THEN
- BEGIN
- inUp := FALSE;
- InvertRgn(upRgn);
- END;
- IF inDown THEN
- BEGIN
- inDown := FALSE;
- InvertRgn(downRgn);
- END;
- END;
- END
- UNTIL NOT StillDown;
-
- IF inUp THEN (* clean things up before leaving *)
- BEGIN
- InvertRgn(upRgn);
- END;
- IF inDown THEN
- BEGIN
- InvertRgn(downRgn);
- END;
-
- SetRefConRate(rate); (* if it has chaged will store new value *)
-
- DisposeRgn(upRgn);
- DisposeRgn(downRgn);
- DisposeRgn(rRgn);
- TextMode(srcOr);
- END;
-
-
- PROCEDURE DoContent(VAR where: Point; what: WindowPtr);
- VAR whichControl: ControlHandle;
- controlID: Integer;
-
- BEGIN
- GlobalToLocal(where);
- IF ( FindControl(where, what, whichControl) <> 0 ) THEN
- BEGIN
- controlID := GetControlID(whichControl, what);
- IF ( TrackControl(whichControl, where, ProcPtr(-1)) <> 0) THEN
- BEGIN
- CASE controlID OF
- 128:;
- 129:SetLoop( controlID);
- 130:SetLoop( controlID);
- 131:SetLoop( controlID);
- 132:SetPreferredRate( controlID);
- 133:ResetPreferredRate( controlID);
- OTHERWISE
- DebugStr('Bummer: could not find the control');
- END
- END
- END
- ELSE
- IF InArrows(where) THEN
- TrackArrows(where);
- END;
-
- PROCEDURE DoMouseDown(theEvent:EventRecord);
- {
- purpose identify where mouse was clicked and handle it
- }
- VAR
- Location : Integer;
- theWindow : WindowPtr;
- MLoc : Point;
- WLoc : Integer;
-
- BEGIN
- MLoc := theEvent.Where; { get mouse position }
- WLoc := FindWindow(MLoc,theWindow); { get window, loc in window }
- CASE WLoc OF { handle window locations }
- InGoAway : HandleGoAway(theWindow,MLoc); { in the go away box}
- InContent: DoContent(MLoc, theWindow);
- OTHERWISE ;
- END;
- END; { of proc DoMouseDown }
-
- PROCEDURE UpdateStuff(what: WindowPtr);
-
- BEGIN
- BeginUpdate(what);
- SetPort(what);
- DrawPicture(gArrows, gArrows^^.picFrame);
- DrawControls(what);
- DrawShuttleValue(TRUE);
- DrawContents;
- EndUpdate(what);
- END;
-
- PROCEDURE HandleEvent(theEvent : EventRecord);
- {
- purpose decodes event and handles it
- }
- BEGIN
- CASE theEvent.What OF
- mouseDown : DoMouseDown(theEvent); { mouse button pushed }
- updateEvt: UpdateStuff(WindowPtr(theEvent.message));
- END
- END; { of proc HandleEvent }
-
- PROCEDURE InitVars;
- BEGIN
- { Initialization of variables used for time base samples }
- gDoneFlag := FALSE; { to begin with }
- gLooping := FALSE;
- END;
-
- FUNCTION InitSystem: OSErr;
- {
- purpose initialize everything for the program
- returns an error if QuickTIme is not present or
- if EnterMovies failed.
- }
- VAR
- result: OSErr;
- arrow: PicHandle;
-
- FUNCTION GetGestaltResult(gestaltSelector: OSType):Integer;
- VAR
- result : LONGINT;
-
- BEGIN
- IF Gestalt(gestaltSelector, result) = noErr THEN
- GetGestaltResult := result
- ELSE
- GetGestaltResult := 0;
- END;
-
- BEGIN
-
- MaxApplZone;
-
- { initialize all the different managers }
- InitGraf(@thePort); { create a grafport for the screen }
- InitFonts; { start up the font manager }
- InitWindows; { start up the window manager }
- InitMenus; { start up the menu manager }
- TEInit; { start up the text manager for DAs }
- InitDialogs(NIL); { start up the dialog manager }
- FlushEvents(everyEvent,0); { clear events from previous state }
-
- WITH gMoovBox DO { Use this routine to init the window rect }
- BEGIN
- top:= 10;
- left:= 300;
- bottom := 190;
- right := 480;
- END;
-
- arrow := PicHandle(GetResource('PICT', arrowsID));
- IF arrow <> NIL THEN
- BEGIN
- DetachResource(Handle(arrow));
- gArrows := arrow;
- END
- ELSE
- gArrows := NIL;
- InitVars; { to begin with }
-
- gSystemVersion := GetGestaltResult (gestaltSystemVersion);
-
- IF GetGestaltResult(gestaltQuickTime) <> 0 THEN { zero means no such selector }
- result:= EnterMovies
- ELSE
- result := movieToolboxUnitialized;
- InitSystem := result;
-
- END; (* InitSystem *)
-
- PROCEDURE ConvertOldToNew(oldSF: SFReply; VAR newSF: StandardFileReply);
- {
- purpose converts an old style SFReply inot a system 7
- StandardFileReply.
- }
- VAR err: OSErr;
- ignoreProc: LONGINT;
-
- BEGIN
- WITH newSF, oldSF DO
- BEGIN
- sfGood := good;
- sfReplacing := copy;
- sfType := fType;
- err := FSMakeFSSpec(vRefNum, 0, fName, sfFile);
- sfScript := iuSystemScript;
- sfFlags := 0;
- sfIsFolder := false;
- sfIsVolume := false;
- sfReserved1 := 0;
- sfReserved2 := 0;
- END;
- END;
-
- FUNCTION DisplayGetFile(prompt: Str255; VAR reply: StandardFileReply): BOOLEAN;
- {
- purpose promp the user to select a file works in both system 6 and 7.
- }
- VAR fileTypes: SFTypeList;
- localReply: SFReply;
- where: Point;
- err: OSerr;
- BEGIN
- where.h:=100;
- where.v:=100;
- fileTypes[0]:='MooV';
-
- IF gSystemVersion >= $0700 THEN { new standard file available }
- StandardGetFilePreview(nil, 1, fileTypes, reply)
- ELSE
- BEGIN
- SFGetFIle(where, prompt, nil, 1, fileTypes, nil, localReply);
- ConvertOldToNew(localReply, reply);
- END;
- DisplayGetFile := reply.sfGood;
- END;
-
- (******* END Auxiliary routines ********************************************************)
-
-